package org.demo.base.jdbc.datasource;

import com.alibaba.druid.pool.DruidDataSource;
import com.mysql.jdbc.Driver;

import javax.sql.DataSource;
import java.sql.SQLException;

public class DataSourceUtil {

    private static DruidDataSource dataSource = new DruidDataSource();

    static {
        dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/zhaofei");
        dataSource.setUsername("root");
        dataSource.setPassword("root");
        try {
            dataSource.setDriver(new Driver());
        } catch (SQLException e) {
            e.printStackTrace();
        };
    }

    public static DataSource getDataSource(){
        return dataSource;
    }
}
